<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        li{
            list-style: none;
        }
    </style>
</head>

<body>
    <div id="app">
        <input v-model="val" type="text">
        <button @click="addItem">添加</button>
        <div>
            <h2>正在进行 {{len}}</h2>
            <ul>
                <li v-for="(item, index) in arr"    v-show="!item.checked">
                    <input v-model="item.checked" type="checkbox">
                    <span>{{item.val}}</span>
                    <button @click="removeItem(index)">删除</button>
                </li>
            </ul>
            <h2>已完成  {{arr.length - len}}</h2>
            <ul>
                <li v-for="(item,index) in arr" v-show="item.checked">
                    <input v-model="item.checked" type="checkbox">
                    <span>{{item.val}}</span>
                    <button @click="removeItem">删除</button>
                </li>
            </ul>
        </div>
    </div>
   


    <script src="./vue.js"></script>

    <script>
        new Vue({
            el:" #app ",
            data:{
                val:"",
                arr:[],
                index:0
            },
            computed:{
                len(){
                    return this.arr.filter((item)=>{
                        return item.checked === false
                    }).length
                }
            },
            methods:{
                addItem(){
                    this.arr.push({
                        val:this.val,
                        checked:false,
                        
                    })
                    console.log(this.val)
                    this.val = " "
                },
                removeItem(num){
                    this.arr.splice(num,1)
                    this.val =" "
                }
            }
        })
    </script>
</body>
</html>